﻿using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace QMERP.Infrastructure.EFCore.Migrations
{
    /// <inheritdoc />
    public partial class init4 : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "Contract_Lens_SalesProcess");

            migrationBuilder.DropTable(
                name: "Lens_SalesProcess");

            migrationBuilder.DropColumn(
                name: "EnterStockQty",
                table: "TransferLensOrderDetail_LensDetail");

            migrationBuilder.DropColumn(
                name: "Number",
                table: "SalesProcess");

            migrationBuilder.CreateTable(
                name: "Contract_Lens_SalesProcessConstraint",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    IsCombination = table.Column<bool>(type: "bit", nullable: false),
                    JuSe = table.Column<string>(type: "nvarchar(6)", maxLength: 6, nullable: true),
                    ChaSe = table.Column<string>(type: "nvarchar(6)", maxLength: 6, nullable: true),
                    ShuiYin = table.Column<string>(type: "nvarchar(6)", maxLength: 6, nullable: true),
                    RanSe = table.Column<string>(type: "nvarchar(10)", maxLength: 10, nullable: true),
                    UV = table.Column<bool>(type: "bit", nullable: false),
                    JingJia = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: true),
                    JiaYing = table.Column<bool>(type: "bit", nullable: false),
                    PaoGuang = table.Column<bool>(type: "bit", nullable: false),
                    CaiBian = table.Column<string>(type: "nvarchar(4)", maxLength: 4, nullable: true),
                    CheBian = table.Column<string>(type: "nvarchar(10)", maxLength: 10, nullable: true),
                    KaiKeng = table.Column<string>(type: "nvarchar(2)", maxLength: 2, nullable: true),
                    PiHua = table.Column<string>(type: "nvarchar(2)", maxLength: 2, nullable: true),
                    DaoBian = table.Column<string>(type: "nvarchar(10)", maxLength: 10, nullable: true),
                    MianWan = table.Column<string>(type: "nvarchar(10)", maxLength: 10, nullable: true),
                    ZuanKong = table.Column<string>(type: "nvarchar(10)", maxLength: 10, nullable: true),
                    OtherProcess = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: true),
                    ExtraProcess = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: true),
                    PricePcs = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false),
                    PricePairs = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false),
                    InvoiceStrENG = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
                    InvoiceStrCHS = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
                    InvoiceStrCHT = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
                    ContractId = table.Column<long>(type: "bigint", nullable: false),
                    LensId = table.Column<long>(type: "bigint", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Contract_Lens_SalesProcessConstraint", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Contract_Lens_SalesProcessConstraint_Contract_ContractId",
                        column: x => x.ContractId,
                        principalTable: "Contract",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_Contract_Lens_SalesProcessConstraint_Lens_LensId",
                        column: x => x.LensId,
                        principalTable: "Lens",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "Lens_SalesProcessConstraint",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    JuSe = table.Column<string>(type: "nvarchar(6)", maxLength: 6, nullable: true),
                    ChaSe = table.Column<string>(type: "nvarchar(6)", maxLength: 6, nullable: true),
                    ShuiYin = table.Column<string>(type: "nvarchar(6)", maxLength: 6, nullable: true),
                    RanSe = table.Column<string>(type: "nvarchar(10)", maxLength: 10, nullable: true),
                    UV = table.Column<bool>(type: "bit", nullable: false),
                    JingJia = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: true),
                    JiaYing = table.Column<bool>(type: "bit", nullable: false),
                    PaoGuang = table.Column<bool>(type: "bit", nullable: false),
                    CaiBian = table.Column<string>(type: "nvarchar(4)", maxLength: 4, nullable: true),
                    CheBian = table.Column<string>(type: "nvarchar(10)", maxLength: 10, nullable: true),
                    KaiKeng = table.Column<string>(type: "nvarchar(2)", maxLength: 2, nullable: true),
                    PiHua = table.Column<string>(type: "nvarchar(2)", maxLength: 2, nullable: true),
                    DaoBian = table.Column<string>(type: "nvarchar(10)", maxLength: 10, nullable: true),
                    MianWan = table.Column<string>(type: "nvarchar(10)", maxLength: 10, nullable: true),
                    ZuanKong = table.Column<string>(type: "nvarchar(10)", maxLength: 10, nullable: true),
                    OtherProcess = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: true),
                    ExtraProcess = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: true),
                    IsForce = table.Column<bool>(type: "bit", nullable: false),
                    LensId = table.Column<long>(type: "bigint", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Lens_SalesProcessConstraint", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Lens_SalesProcessConstraint_Lens_LensId",
                        column: x => x.LensId,
                        principalTable: "Lens",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_Contract_Lens_SalesProcessConstraint_ContractId",
                table: "Contract_Lens_SalesProcessConstraint",
                column: "ContractId");

            migrationBuilder.CreateIndex(
                name: "IX_Contract_Lens_SalesProcessConstraint_Id",
                table: "Contract_Lens_SalesProcessConstraint",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_Contract_Lens_SalesProcessConstraint_LensId",
                table: "Contract_Lens_SalesProcessConstraint",
                column: "LensId");

            migrationBuilder.CreateIndex(
                name: "IX_Lens_SalesProcessConstraint_Id",
                table: "Lens_SalesProcessConstraint",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_Lens_SalesProcessConstraint_LensId",
                table: "Lens_SalesProcessConstraint",
                column: "LensId");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "Contract_Lens_SalesProcessConstraint");

            migrationBuilder.DropTable(
                name: "Lens_SalesProcessConstraint");

            migrationBuilder.AddColumn<int>(
                name: "EnterStockQty",
                table: "TransferLensOrderDetail_LensDetail",
                type: "int",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.AddColumn<string>(
                name: "Number",
                table: "SalesProcess",
                type: "nvarchar(20)",
                maxLength: 20,
                nullable: false,
                defaultValue: "");

            migrationBuilder.CreateTable(
                name: "Contract_Lens_SalesProcess",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Contract_LensId = table.Column<long>(type: "bigint", nullable: false),
                    SalesProcessId = table.Column<long>(type: "bigint", nullable: false),
                    InvoiceStrCHS = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
                    InvoiceStrCHT = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
                    InvoiceStrENG = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
                    IsCombination = table.Column<bool>(type: "bit", nullable: false),
                    PricePairs = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false),
                    PricePcs = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Contract_Lens_SalesProcess", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Contract_Lens_SalesProcess_Contract_Lens_Contract_LensId",
                        column: x => x.Contract_LensId,
                        principalTable: "Contract_Lens",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_Contract_Lens_SalesProcess_SalesProcess_SalesProcessId",
                        column: x => x.SalesProcessId,
                        principalTable: "SalesProcess",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "Lens_SalesProcess",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    LensId = table.Column<long>(type: "bigint", nullable: false),
                    SalesProcessId = table.Column<long>(type: "bigint", nullable: true),
                    IsForce = table.Column<bool>(type: "bit", nullable: false),
                    ProcessId = table.Column<long>(type: "bigint", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Lens_SalesProcess", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Lens_SalesProcess_Lens_LensId",
                        column: x => x.LensId,
                        principalTable: "Lens",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_Lens_SalesProcess_SalesProcess_SalesProcessId",
                        column: x => x.SalesProcessId,
                        principalTable: "SalesProcess",
                        principalColumn: "Id");
                });

            migrationBuilder.CreateIndex(
                name: "IX_Contract_Lens_SalesProcess_Contract_LensId",
                table: "Contract_Lens_SalesProcess",
                column: "Contract_LensId");

            migrationBuilder.CreateIndex(
                name: "IX_Contract_Lens_SalesProcess_Id",
                table: "Contract_Lens_SalesProcess",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_Contract_Lens_SalesProcess_SalesProcessId",
                table: "Contract_Lens_SalesProcess",
                column: "SalesProcessId");

            migrationBuilder.CreateIndex(
                name: "IX_Lens_SalesProcess_Id",
                table: "Lens_SalesProcess",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_Lens_SalesProcess_LensId",
                table: "Lens_SalesProcess",
                column: "LensId");

            migrationBuilder.CreateIndex(
                name: "IX_Lens_SalesProcess_ProcessId",
                table: "Lens_SalesProcess",
                column: "ProcessId");

            migrationBuilder.CreateIndex(
                name: "IX_Lens_SalesProcess_SalesProcessId",
                table: "Lens_SalesProcess",
                column: "SalesProcessId");
        }
    }
}
